package com.ele.client;

import com.ele.client.activity.auth.LoginActivity;
import com.ele.client.activity.auth.LoginPlace;
import com.ele.client.activity.auth.RegistrationActivity;
import com.ele.client.activity.auth.RegistrationPlace;
import com.ele.client.activity.editor.EditorActivity;
import com.ele.client.activity.editor.EditorPlace;
import com.ele.client.activity.home.HomeActivity;
import com.ele.client.activity.home.HomePlace;
import com.ele.client.activity.terminal.TerminalActivity;
import com.ele.client.activity.terminal.TerminalPlace;
import com.google.gwt.activity.shared.Activity;
import com.google.gwt.activity.shared.ActivityMapper;
import com.google.gwt.place.shared.Place;

public class AppActivityMapper implements ActivityMapper {
    private ClientFactory clientFactory;

    public AppActivityMapper(ClientFactory clientFactory) {
        super();
        this.clientFactory = clientFactory;
    }

    @Override
    public Activity getActivity(Place place) {
        if (place instanceof LoginPlace)
            return new LoginActivity((LoginPlace) place, clientFactory);
        else if (place instanceof RegistrationPlace)
            return new RegistrationActivity((RegistrationPlace) place, clientFactory);
        else if (place instanceof EditorPlace)
            return new EditorActivity((EditorPlace) place, clientFactory);
        else if (place instanceof HomePlace)
            return new HomeActivity((HomePlace) place, clientFactory);
        else if (place instanceof TerminalPlace)
            return new TerminalActivity((TerminalPlace) place, clientFactory);
        return null;
    }
}
